//
//  Mother.m
//  KVODemo
//
//  Created by shk on 14/12/10.
//  Copyright (c) 2014年 com.shk. All rights reserved.
//

#import "Mother.h"
#import "Child.h"

@implementation Mother

-(id) initWithChild:(Child*) child{
    self = [super init];
    if(self != nil){
        self.child = child;
        [child addObserver:self forKeyPath:@"walk" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:@"xxx"];//注册监听
    }
    return self;
}

//监听（因addObserver的值是self，所以需要写在当前类中）
-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    
    NSLog(@"mother observer walk：%@", change);

}


@end
